package cn.gailvlun.gll.presentation.login

import android.content.Context
import android.content.Intent
import android.databinding.DataBindingUtil
import android.os.Bundle
import android.view.View
import android.view.Window
import android.view.WindowManager
import cn.gailvlun.gll.R
import cn.gailvlun.gll.databinding.ActivityWelcomeBinding
import cn.gailvlun.gll.presentation.base.BaseActivity


class WelcomeActivity : BaseActivity() {

    companion object {
        @JvmStatic
        fun openActivity(context: Context, clearOthers: Boolean) {
            val clearIntent = Intent(context, WelcomeActivity::class.java)
            if (clearOthers) {
                clearIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
            }
            context.startActivity(clearIntent)
        }
    }

    override fun initComponent() {
        requestWindowFeature(Window.FEATURE_NO_TITLE)
        window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN)
        val binding = DataBindingUtil.setContentView<ActivityWelcomeBinding>(this, R.layout.activity_welcome)
        binding.vm = ViewModel()
    }

    override fun createHandler() {
    }

    override fun loadData(savedInstanceState: Bundle?) {
    }


    inner class ViewModel {
        fun onLogin(view: View) {
            LoginActivity.openActivity(mContext, true)

        }

        fun onRegister(view: View) {
            RegisterActivity.openActivity(mContext)

        }
    }
}